﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DatNuocViet.Models;

namespace DatNuocViet.Controllers
{
    public class GratitudeController : Controller
    {
        //
        // GET: /Gratitude/

        public ActionResult Index()
        {
            List<GetToursImageResult> model = new List<GetToursImageResult>();
            GetWebResourceResult model1 = new GetWebResourceResult();
            using (DatNuocVietDbDataContext db = new DatNuocVietDbDataContext())
            {
                model = db.GetToursImage(0).ToList();
                model1 = db.GetWebResource("datnuocviet.trian").FirstOrDefault();

                ViewBag.commnentList = db.Comments.Where(p=>p.isDelete != true).ToList();
            }
            ViewData["Content"] = model1;
            ViewBag.Title = Ultility.Helper.Label("trian");
            return View(model);
        }

        [HttpPost]
        public ActionResult CusComment(FormCollection frm)
        {
            using (DatNuocVietDbDataContext db = new DatNuocVietDbDataContext())
            {
                Comment cmt = new Comment();
                cmt.Author = frm["hoTen"];
                cmt.CommentContent = frm["NoiDung"];
                cmt.isDelete = false;

                db.Comments.InsertOnSubmit(cmt);
                db.SubmitChanges();
            }

            return RedirectToAction("Index");
        }

    }
}
